//
//  KZProductDetailInformationCell.swift
//  BoyeStore
//
//  Created by 朱凯 on 2018/6/26.
//  Copyright © 2018年 itboye. All rights reserved.
//

import UIKit

class KZProductDetailInformationCell: UITableViewCell {
    
    let nameLabel = UILabel()       // 名字
    let priceLabel = UILabel()      // 现价
    let oldPriceLabel = UILabel()   // 原价
    let salesLabel = UILabel()      // 已售
    let noteLabel = UILabel()       // 备注
    

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

// MARK: ------ 创建视图
extension KZProductDetailInformationCell {
    
    func setupUI() {
    
        nameLabel.textColor = UIColor.black
        nameLabel.numberOfLines = 0
        nameLabel.textAlignment = .left
        nameLabel.text = "智能心率手环、手表(连接手机)qqqqqqqqqqqqq方式寄到废旧塑料富士康方式来看仅发送垃圾来看圣诞快乐废旧塑料发售了地方就杀戮空间是"
        nameLabel.font = UIFont.systemFont(ofSize: 15)
        contentView.addSubview(nameLabel)
        nameLabel.snp.makeConstraints { (m) in
            m.left.equalTo(10)
            m.right.equalTo(-10)
            m.top.equalTo(15)
            // 高度自适应
        }
        
        priceLabel.textColor = kThemeColor
        priceLabel.textAlignment = .left
        priceLabel.text = "￥125.0"
        priceLabel.font = UIFont.systemFont(ofSize: 20)
        contentView.addSubview(priceLabel)
        priceLabel.snp.makeConstraints { (m) in
            m.left.equalTo(nameLabel)
            m.top.equalTo(nameLabel.snp.bottom).offset(10)
            // 高度自适应
        }
        
        oldPriceLabel.textColor = UIColor.lightGray
        oldPriceLabel.textAlignment = .left
        oldPriceLabel.text = "￥188.0"
        oldPriceLabel.font = UIFont.systemFont(ofSize: 15)
        contentView.addSubview(oldPriceLabel)
        oldPriceLabel.snp.makeConstraints { (m) in
            m.left.equalTo(priceLabel.snp.right).offset(10)
            m.bottom.height.equalTo(priceLabel)
        }
        oldPriceLabel.attributedText = oldPriceLabel.text?.attrubutesString(attrubutes: [NSAttributedStringKey.strikethroughStyle: 2])
        
        salesLabel.textColor = UIColor.lightGray
        salesLabel.adjustsFontSizeToFitWidth = true
        salesLabel.textAlignment = .left
        salesLabel.text = "已售3000件"
        salesLabel.font = UIFont.systemFont(ofSize: 10)
        contentView.addSubview(salesLabel)
        salesLabel.snp.makeConstraints { (m) in
            m.right.equalTo(nameLabel)
            m.bottom.equalTo(priceLabel)
        }
        
        noteLabel.textColor = kThemeColor
        noteLabel.numberOfLines = 0
        noteLabel.adjustsFontSizeToFitWidth = true
        noteLabel.textAlignment = .left
        noteLabel.text = "本次优惠仅限三天，立即下单更有优惠本次优惠仅限三天，立即下单更有优惠本次优惠仅限三天，立即下单更有优惠"
        noteLabel.font = UIFont.systemFont(ofSize: 11)
        contentView.addSubview(noteLabel)
        noteLabel.snp.makeConstraints { (m) in
            m.left.right.equalTo(nameLabel)
            m.height.equalTo(40)
            m.top.equalTo(priceLabel.snp.bottom).offset(10)
            
            m.bottom.equalTo(0)
        }
        
        let line = UIView()
        self.addSubview(line)
        line.backgroundColor = kBgColor
        line.snp.makeConstraints { (m) in
            m.left.right.equalTo(0)
            m.top.equalTo(noteLabel)
            m.height.equalTo(1)
        }
        
        
        
        
    }
}
